<!DOCTYPE HTML>
<html lang="zh-tw" >
    <!-- Start book python高级 -->
    <head>
        <!-- head:start -->
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge" />
        <title>GIL问题 | python高级</title>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
        <meta name="description" content="">
        <meta name="generator" content="GitBook 2.6.7">
        
        
        <meta name="HandheldFriendly" content="true"/>
        <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <link rel="apple-touch-icon-precomposed" sizes="152x152" href="../gitbook/images/apple-touch-icon-precomposed-152.png">
        <link rel="shortcut icon" href="../gitbook/images/favicon.ico" type="image/x-icon">
        
    <link rel="stylesheet" href="../gitbook/style.css">
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-toggle-chapters/toggle.css">
        
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-splitter/splitter.css">
        
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-emphasize/plugin.css">
        
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-highlight/website.css">
        
    
        
        <link rel="stylesheet" href="../gitbook/plugins/gitbook-plugin-fontsettings/website.css">
        
    
    

        
    
    
    <link rel="next" href="../day11/02.copy.html" />
    
    
    <link rel="prev" href="../day11/00.readme.html" />
    

        <!-- head:end -->
    </head>
    <body>
        <!-- body:start -->
        
    <div class="book"
        data-level="1.1"
        data-chapter-title="GIL问题"
        data-filepath="day11/01.GIL.md"
        data-basepath=".."
        data-revision="Wed Sep 26 2018 22:46:13 GMT+0800 (CST)"
        data-innerlanguage="">
    

<div class="book-summary">
    <nav role="navigation">
        <ul class="summary">
            
            
            
            

            

            
    
        <li class="chapter " data-level="0" data-path="index.html">
            
                
                    <a href="../index.html">
                
                        <i class="fa fa-check"></i>
                        
                        Python高级
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1" data-path="day11/00.readme.html">
            
                
                    <a href="../day11/00.readme.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.</b>
                        
                        Python语法高级专题1
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter active" data-level="1.1" data-path="day11/01.GIL.html">
            
                
                    <a href="../day11/01.GIL.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.1.</b>
                        
                        GIL问题
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.2" data-path="day11/02.copy.html">
            
                
                    <a href="../day11/02.copy.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.2.</b>
                        
                        赋值-浅拷贝-深拷贝
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.3" data-path="day11/03.import.html">
            
                
                    <a href="../day11/03.import.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.3.</b>
                        
                        import导入模块
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="1.4" data-path="day11/04.review.html">
            
                
                    <a href="../day11/04.review.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>1.4.</b>
                        
                        总结
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="2" data-path="day12/00.readme.html">
            
                
                    <a href="../day12/00.readme.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.</b>
                        
                        Python语法高级专题2
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="2.1" data-path="day12/01.mro.html">
            
                
                    <a href="../day12/01.mro.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.1.</b>
                        
                        多继承和MRO顺序
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.2" data-path="day12/02.property.html">
            
                
                    <a href="../day12/02.property.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.2.</b>
                        
                        property属性
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.3" data-path="day12/03.magic.html">
            
                
                    <a href="../day12/03.magic.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.3.</b>
                        
                        魔法属性和方法
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.4" data-path="day12/04.with.html">
            
                
                    <a href="../day12/04.with.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.4.</b>
                        
                        with管理上下文
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="2.5" data-path="day12/05.review.html">
            
                
                    <a href="../day12/05.review.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>2.5.</b>
                        
                        总结
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="3" data-path="day13/00.readme.html">
            
                
                    <a href="../day13/00.readme.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.</b>
                        
                        Python语法之装饰器
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="3.1" data-path="day13/01.closure.html">
            
                
                    <a href="../day13/01.closure.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.1.</b>
                        
                        闭包
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.2" data-path="day13/02.decorator.html">
            
                
                    <a href="../day13/02.decorator.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.2.</b>
                        
                        装饰器
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="3.3" data-path="day13/03.review.html">
            
                
                    <a href="../day13/03.review.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>3.3.</b>
                        
                        总结
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4" data-path="day14/00.readme.html">
            
                
                    <a href="../day14/00.readme.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.</b>
                        
                        MySQL数据库基本操作
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.1" data-path="day14/01.数据库概述.html">
            
                
                    <a href="../day14/01.数据库概述.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.1.</b>
                        
                        数据库概述
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.2" data-path="day14/02.数据类型和约束.html">
            
                
                    <a href="../day14/02.数据类型和约束.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.2.</b>
                        
                        数据完整性
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.3" data-path="day14/03.Navicat.html">
            
                
                    <a href="../day14/03.Navicat.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.3.</b>
                        
                        图形化客户端Navicat
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.4" data-path="day14/04.命令行客户端.html">
            
                
                    <a href="../day14/04.命令行客户端.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.4.</b>
                        
                        命令行客户端SQL的使用
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="4.4.1" data-path="day14/05.sql_con.html">
            
                
                    <a href="../day14/05.sql_con.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.4.1.</b>
                        
                        登录和退出数据库
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.4.2" data-path="day14/07.sql_table_struct.html">
            
                
                    <a href="../day14/07.sql_table_struct.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.4.2.</b>
                        
                        表结构的操作
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.4.3" data-path="day14/06.sql_database.html">
            
                
                    <a href="../day14/06.sql_database.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.4.3.</b>
                        
                        数据库的操作
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="4.4.4" data-path="day14/08.表数据操作.html">
            
                
                    <a href="../day14/08.表数据操作.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.4.4.</b>
                        
                        表数据的操作
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="4.5" data-path="day14/09.review.html">
            
                
                    <a href="../day14/09.review.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>4.5.</b>
                        
                        知识总结
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="5" data-path="day15/00.readme.html">
            
                
                    <a href="../day15/00.readme.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.</b>
                        
                        MYSQL数据库进阶操作
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="5.1" data-path="day15/01.练习.html">
            
                
                    <a href="../day15/01.练习.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.1.</b>
                        
                        练习强化
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.2" data-path="day15/02.where条件.html">
            
                
                    <a href="../day15/02.where条件.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.2.</b>
                        
                        条件
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.3" data-path="day15/03.排序查询.html">
            
                
                    <a href="../day15/03.排序查询.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.3.</b>
                        
                        排序
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.4" data-path="day15/04.分页查询.html">
            
                
                    <a href="../day15/04.分页查询.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.4.</b>
                        
                        分页
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.5" data-path="day15/05.聚合函数.html">
            
                
                    <a href="../day15/05.聚合函数.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.5.</b>
                        
                        聚合函数
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.6" data-path="day15/06.分组.html">
            
                
                    <a href="../day15/06.分组.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.6.</b>
                        
                        分组
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.7" data-path="day15/07.连接.html">
            
                
                    <a href="../day15/07.连接.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.7.</b>
                        
                        连接
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.8" data-path="day15/08.自连接.html">
            
                
                    <a href="../day15/08.自连接.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.8.</b>
                        
                        自连接
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.9" data-path="day15/09.子查询.html">
            
                
                    <a href="../day15/09.子查询.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.9.</b>
                        
                        子查询
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="5.10" data-path="day15/10.总结.html">
            
                
                    <a href="../day15/10.总结.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>5.10.</b>
                        
                        总结
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="6" data-path="day16/readme.html">
            
                
                    <a href="../day16/readme.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.</b>
                        
                        MYSQL数据库编程
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="6.1" data-path="day16/data.html">
            
                
                    <a href="../day16/data.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.1.</b>
                        
                        数据准备
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.2" data-path="day16/sql_code.html">
            
                
                    <a href="../day16/sql_code.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.2.</b>
                        
                        SQL演练
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.3" data-path="day16/dbdesign.html">
            
                
                    <a href="../day16/dbdesign.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.3.</b>
                        
                        数据库设计
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.4" data-path="day16/pymysql.html">
            
                
                    <a href="../day16/pymysql.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.4.</b>
                        
                        数据库编程
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="6.5" data-path="day16/zongjie.html">
            
                
                    <a href="../day16/zongjie.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>6.5.</b>
                        
                        总结
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="7" data-path="day17/00.readme.html">
            
                
                    <a href="../day17/00.readme.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.</b>
                        
                        MySQL数据库高级用法
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="7.1" data-path="day17/01.view.html">
            
                
                    <a href="../day17/01.view.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.1.</b>
                        
                        视图
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.2" data-path="day17/02.transaction.html">
            
                
                    <a href="../day17/02.transaction.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.2.</b>
                        
                        事务
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.3" data-path="day17/03.sql_index.html">
            
                
                    <a href="../day17/03.sql_index.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.3.</b>
                        
                        索引
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.4" data-path="day17/04.user.html">
            
                
                    <a href="../day17/04.user.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.4.</b>
                        
                        用户管理
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.5" data-path="day17/05.master_slave.html">
            
                
                    <a href="../day17/05.master_slave.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.5.</b>
                        
                        主从配置
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="7.6" data-path="day17/06.review.html">
            
                
                    <a href="../day17/06.review.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>7.6.</b>
                        
                        总结
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    
        <li class="chapter " data-level="8" data-path="day18/00.readme.html">
            
                
                    <a href="../day18/00.readme.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.</b>
                        
                        miniweb框架
                    </a>
            
            
            <ul class="articles">
                
    
        <li class="chapter " data-level="8.1" data-path="day18/01.框架是什么.html">
            
                
                    <a href="../day18/01.框架是什么.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.1.</b>
                        
                        框架概念
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.2" data-path="day18/02.实现框架.html">
            
                
                    <a href="../day18/02.实现框架.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.2.</b>
                        
                        实现一个简单的框架
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.3" data-path="day18/03.模板.html">
            
                
                    <a href="../day18/03.模板.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.3.</b>
                        
                        模板替换
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.4" data-path="day18/04.路由.html">
            
                
                    <a href="../day18/04.路由.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.4.</b>
                        
                        路由概念
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.5" data-path="day18/05.显示股票数据.html">
            
                
                    <a href="../day18/05.显示股票数据.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.5.</b>
                        
                        股票收藏夹
                    </a>
            
            
        </li>
    
        <li class="chapter " data-level="8.6" data-path="day18/05.review.html">
            
                
                    <a href="../day18/05.review.html">
                
                        <i class="fa fa-check"></i>
                        
                            <b>8.6.</b>
                        
                        复习
                    </a>
            
            
        </li>
    

            </ul>
            
        </li>
    


            
            <li class="divider"></li>
            <li>
                <a href="https://www.gitbook.com" target="blank" class="gitbook-link">
                    本書使用 GitBook 釋出
                </a>
            </li>
            
        </ul>
    </nav>
</div>

    <div class="book-body">
        <div class="body-inner">
            <div class="book-header" role="navigation">
    <!-- Actions Left -->
    

    <!-- Title -->
    <h1>
        <i class="fa fa-circle-o-notch fa-spin"></i>
        <a href="../" >python高级</a>
    </h1>
</div>

            <div class="page-wrapper" tabindex="-1" role="main">
                <div class="page-inner">
                
                
                    <section class="normal" id="section-">
                    
                        <h1 id="1-gil">1 GIL</h1>
<h2 id="11-&#x76EE;&#x6807;">1.1 &#x76EE;&#x6807;</h2>
<ul>
<li>&#x77E5;&#x9053;GIL&#x7684;&#x4F5C;&#x7528;</li>
<li>&#x77E5;&#x9053;GIL&#x5BF9;&#x591A;&#x7EBF;&#x7A0B;&#x6267;&#x884C;&#x7684;&#x5F71;&#x54CD;</li>
</ul>
<h2 id="12-gil&#x5168;&#x5C40;&#x89E3;&#x91CA;&#x5668;&#x9501;">1.2 GIL&#x5168;&#x5C40;&#x89E3;&#x91CA;&#x5668;&#x9501;</h2>
<p> &#x987E;&#x540D;&#x601D;&#x4E49;&#xFF0C;&#x8FD9;&#x662F;&#x89E3;&#x91CA;&#x5668;&#x5185;&#x90E8;&#x7684;&#x4E00;&#x628A;&#x9501;&#xFF0C;&#x786E;&#x5207;&#x4E00;&#x70B9;&#x8BF4;&#x662F;CPython&#x89E3;&#x91CA;&#x5668;&#x5185;&#x90E8;&#x7684;&#x4E00;&#x628A;&#x9501;&#xFF0C;&#x6240;&#x4EE5;&#x8981;&#x6CE8;&#x610F;&#x533A;&#x5206; &#x8FD9;&#x548C;&#x6211;&#x4EEC;&#x5728;Python&#x4EE3;&#x7801;&#x4E2D;&#x4F7F;&#x7528;Lock&#x4E0D;&#x662F;&#x4E00;&#x4E2A;&#x5C42;&#x9762;&#x7684;&#x6982;&#x5FF5;&#x3002;</p>
<blockquote>
<p>GIL&#x4EA7;&#x751F;&#x7684;&#x80CC;&#x666F;
 &#x5728;CPython&#x89E3;&#x91CA;&#x5185;&#x90E8;&#x8FD0;&#x884C;&#x591A;&#x4E2A;&#x7EBF;&#x7A0B;&#x7684;&#x65F6;&#x5019;&#xFF0C;&#x6BCF;&#x4E2A;&#x7EBF;&#x7A0B;&#x90FD;&#x9700;&#x8981;&#x89E3;&#x91CA;&#x5668;&#x5185;&#x90E8;&#x7533;&#x8BF7;&#x76F8;&#x5E94;&#x7684;&#x5168;&#x5C40;&#x8D44;&#x6E90;&#xFF0C;&#x7531;&#x4E8E;C&#x8BED;&#x8A00;&#x672C;&#x8EAB;&#x6BD4;&#x8F83;&#x5E95;&#x5C42;&#x9020;&#x6210;CPython&#x5728;&#x7BA1;&#x7406;&#x6240;&#x6709;&#x5168;&#x5C40;&#x8D44;&#x6E90;&#x7684;&#x65F6;&#x5019;&#x5E76;&#x4E0D;&#x80FD;&#x5E94;&#x5BF9;&#x6240;&#x6709;&#x7EBF;&#x7A0B;&#x540C;&#x65F6;&#x7684;&#x8D44;&#x6E90;&#x8BF7;&#x6C42;&#xFF0C;&#x56E0;&#x6B64;&#x4E3A;&#x4E86;&#x9632;&#x6B62;&#x8D44;&#x6E90;&#x7ADE;&#x4E89;&#x800C;&#x53D1;&#x751F;&#x9519;&#x8BEF;&#xFF0C;&#x5BF9;&#x6240;&#x6709;&#x7EBF;&#x7A0B;&#x7533;&#x8BF7;&#x5168;&#x5C40;&#x8D44;&#x6E90;&#x589E;&#x52A0;&#x4E86;&#x9650;&#x5236;-&#x5168;&#x5C40;&#x89E3;&#x91CA;&#x5668;&#x9501;&#x3002;</p>
</blockquote>
<p> &#x8A00;&#x5916;&#x4E4B;&#x610F;&#xFF0C;&#x5C31;&#x662F;&#x5168;&#x5C40;&#x89E3;&#x91CA;&#x5668;&#x5C31;&#x662F;&#x4E3A;&#x4E86;&#x9501;&#x5B9A;&#x6574;&#x4E2A;&#x89E3;&#x91CA;&#x5668;&#x5185;&#x90E8;&#x7684;&#x5168;&#x5C40;&#x8D44;&#x6E90;&#xFF0C;&#x6BCF;&#x4E2A;&#x7EBF;&#x7A0B;&#x60F3;&#x8981;&#x8FD0;&#x884C;&#x9996;&#x5148;&#x83B7;&#x53D6;GIL&#xFF0C;&#x800C;GIL&#x672C;&#x8EAB;&#x53C8;&#x662F;&#x4E00;&#x628A;&#x4E92;&#x65A5;&#x9501;&#xFF0C;&#x9020;&#x6210;&#x6240;&#x6709;&#x7EBF;&#x7A0B;&#x53EA;&#x80FD;&#x4E00;&#x4E2A;&#x4E00;&#x4E2A;one-by-one-&#x5E76;&#x53D1;-&#x4EA4;&#x66FF;&#x7684;&#x6267;&#x884C;&#x3002;</p>
<blockquote>
<p>GIL&#x4EC0;&#x4E48;&#x65F6;&#x5019;&#x91CA;&#x653E;</p>
<ul>
<li>&#x5728;&#x5F53;&#x524D;&#x7EBF;&#x7A0B;&#x6267;&#x884C;&#x8D85;&#x65F6;&#x540E;&#x4F1A;&#x81EA;&#x52A8;&#x91CA;&#x653E;</li>
<li>&#x5728;&#x5F53;&#x524D;&#x7EBF;&#x7A0B;&#x6267;&#x884C;&#x963B;&#x585E;&#x64CD;&#x4F5C;&#x65F6;&#x4F1A;&#x81EA;&#x52A8;&#x91CA;&#x653E;</li>
<li>&#x5F53;&#x524D;&#x6267;&#x884C;&#x5B8C;&#x6210;&#x65F6;</li>
</ul>
<p>Guido&#x7684;&#x58F0;&#x660E;&#xFF1A;<a href="http://www.artima.com/forums/flat.jsp?forum=106&amp;thread=214235" target="_blank">http://www.artima.com/forums/flat.jsp?forum=106&amp;thread=214235</a>
 Python&#x4E4B;&#x7236;&#x5728;&#x89C2;&#x70B9;&#x7684;&#x6700;&#x540E;&#x90E8;&#x5206;&#x8BF4;&#x660E;
 the language doesn&apos;t require the GIL -- it&apos;s only the CPython virtual machine that has historically been unable to shed it.</p>
</blockquote>
<h3 id="13-gil&#x9762;&#x8BD5;&#x9898;">1.3 GIL&#x9762;&#x8BD5;&#x9898;</h3>
<blockquote>
<p>&#x63CF;&#x8FF0;Python GIL&#x7684;&#x6982;&#x5FF5;&#xFF0C; &#x4EE5;&#x53CA;&#x5B83;&#x5BF9;python&#x591A;&#x7EBF;&#x7A0B;&#x7684;&#x5F71;&#x54CD;&#xFF1F;&#x7F16;&#x5199;&#x4E00;&#x4E2A;&#x591A;&#x7EBF;&#x7A0B;&#x6293;&#x53D6;&#x7F51;&#x9875;&#x7684;&#x7A0B;&#x5E8F;&#xFF0C;&#x5E76;&#x9610;&#x660E;&#x591A;&#x7EBF;&#x7A0B;&#x6293;&#x53D6;&#x7A0B;&#x5E8F;&#x662F;&#x5426;&#x53EF;&#x6BD4;&#x5355;&#x7EBF;&#x7A0B;&#x6027;&#x80FD;&#x6709;&#x63D0;&#x5347;&#xFF0C;&#x5E76;&#x89E3;&#x91CA;&#x539F;&#x56E0;&#x3002;</p>
</blockquote>
<ol>
<li>Python&#x8BED;&#x8A00;&#x548C;GIL&#x6CA1;&#x6709;&#x534A;&#x6BDB;&#x94B1;&#x5173;&#x7CFB;&#x3002;&#x4EC5;&#x4EC5;&#x662F;&#x7531;&#x4E8E;&#x5386;&#x53F2;&#x539F;&#x56E0;&#x5728;Cpython&#x865A;&#x62DF;&#x673A;(&#x89E3;&#x91CA;&#x5668;)&#xFF0C;&#x96BE;&#x4EE5;&#x79FB;&#x9664;GIL&#x3002;</li>
<li><p>. GIL&#xFF1A;&#x5168;&#x5C40;&#x89E3;&#x91CA;&#x5668;&#x9501;&#x3002;&#x6BCF;&#x4E2A;&#x7EBF;&#x7A0B;&#x5728;&#x6267;&#x884C;&#x7684;&#x8FC7;&#x7A0B;&#x90FD;&#x9700;&#x8981;&#x5148;&#x83B7;&#x53D6;GIL&#xFF0C;&#x4FDD;&#x8BC1;&#x540C;&#x4E00;&#x65F6;&#x523B;&#x53EA;&#x6709;&#x4E00;&#x4E2A;&#x7EBF;&#x7A0B;&#x53EF;&#x4EE5;&#x6267;&#x884C;&#x4EE3;&#x7801;&#x3002;</p>
</li>
<li><p>. &#x7EBF;&#x7A0B;&#x91CA;&#x653E;GIL&#x9501;&#x7684;&#x60C5;&#x51B5;&#xFF1A;</p>
<ul>
<li>&#x5728;IO&#x64CD;&#x4F5C;&#x7B49;&#x53EF;&#x80FD;&#x4F1A;&#x5F15;&#x8D77;&#x963B;&#x585E;&#x7684;system call&#x4E4B;&#x524D;,&#x53EF;&#x4EE5;&#x6682;&#x65F6;&#x91CA;&#x653E;GIL,&#x4F46;&#x5728;&#x6267;&#x884C;&#x5B8C;&#x6BD5;&#x540E;,&#x5FC5;&#x987B;&#x91CD;&#x65B0;&#x83B7;&#x53D6;GIL</li>
<li>Python 3.x&#x4F7F;&#x7528;&#x8BA1;&#x65F6;&#x5668;&#xFF08;&#x6267;&#x884C;&#x65F6;&#x95F4;&#x8FBE;&#x5230;&#x9608;&#x503C;&#x540E;&#xFF0C;&#x5F53;&#x524D;&#x7EBF;&#x7A0B;&#x91CA;&#x653E;GIL&#xFF09;&#x6216;Python 2.x&#xFF0C;tickets&#x8BA1;&#x6570;&#x8FBE;&#x5230;100</li>
</ul>
</li>
<li><p>. Python&#x4F7F;&#x7528;&#x591A;&#x8FDB;&#x7A0B;&#x662F;&#x53EF;&#x4EE5;&#x5229;&#x7528;&#x591A;&#x6838;&#x7684;CPU&#x8D44;&#x6E90;&#x7684;&#x3002;</p>
</li>
<li><ol>
<li>&#x591A;&#x7EBF;&#x7A0B;&#x722C;&#x53D6;&#x6BD4;&#x5355;&#x7EBF;&#x7A0B;&#x6027;&#x80FD;&#x6709;&#x63D0;&#x5347;&#xFF0C;&#x56E0;&#x4E3A;&#x9047;&#x5230;IO&#x963B;&#x585E;&#x4F1A;&#x81EA;&#x52A8;&#x91CA;&#x653E;GIL&#x9501;</li>
</ol>
</li>
</ol>
<blockquote>
<p>&#x4E25;&#x91CD;&#x95EE;&#x9898;: &#x65E2;&#x7136;CPython&#x89E3;&#x91CA;&#x5B58;&#x5728;GIL&#x662F;&#x5426;&#x610F;&#x5473;&#x6BCF;&#x4E2A;&#x7EBF;&#x7A0B;&#x5728;&#x5168;&#x5C40;&#x53D8;&#x91CF;&#x5C31;&#x4E0D;&#x7528;&#x52A0;Lock&#x4E92;&#x65A5;&#x9501;&#x4E86;&#x5462;&#xFF1F;
  &#x8FD9;&#x662F;&#x4E00;&#x4E2A;&#x4E25;&#x91CD;&#x9519;&#x8BEF;&#x7684;&#x60F3;&#x6CD5;&#xFF0C;&#x4E3A;&#x4EC0;&#x4E48;&#x7528;&#x6237;&#x64CD;&#x4F5C;&#x5168;&#x5C40;&#x6570;&#x636E;&#x8FD8;&#x9700;&#x8981;&#x52A0;Lock&#xFF0C;&#x56E0;&#x4E3A;GIL&#x7684;&#x91CA;&#x653E;&#x65F6;&#x673A;&#x6211;&#x4EEC;&#x65E0;&#x6CD5;&#x63A7;&#x5236;-&#x64CD;&#x4F5C;&#x975E;&#x5E38;&#x53EF;&#x80FD;&#x5E76;&#x6CA1;&#x6709;&#x5B8C;&#x6210;&#xFF0C;&#x800C;&#x4E0D;&#x50CF;Lock&#x90A3;&#x6837;&#x6211;&#x4EEC;&#x7528;&#x5B8C;&#x624D;&#x91CA;&#x653E;(&#x64CD;&#x4F5C;&#x5B8C;&#x6574;)&#x3002;</p>
</blockquote>
<p>&#x4E3E;&#x4F8B; </p>
<blockquote>
<p>&#x7EBF;&#x7A0B;1 &#x53D6;&#x51FA;&#x5168;&#x5C40;&#x53D8;&#x91CF; g_number == 0 &#x4E00;&#x76F4;&#x52A0;&#x5230;20000&#xFF0C;&#x4F46;&#x662F;&#x8FD8;&#x6CA1;&#x6709;&#x6765;&#x5F97;&#x53CA;&#x5C06;20000&#x5199;&#x5165;g_number&#x4E2D;&#xFF0C;&#x5C31;&#x8D85;&#x65F6;&#x4E86;&#x81EA;&#x52A8;&#x91CA;&#x653E;GIL
  &#x800C;&#x7EBF;&#x7A0B;2 &#x53D6;&#x51FA;g_number==19999 &#x52A0;&#x5230;39999&#x7531;&#x4E8E;&#x8D85;&#x65F6;&#x81EA;&#x52A8;&#x91CA;&#x653E;GIL
  &#x6B64;&#x65F6;&#x7EBF;&#x7A0B;2&#x83B7;&#x53D6;&#x5230;GIL&#x7EE7;&#x7EED;&#x7740;&#x672A;&#x5B8C;&#x6210;&#x7684;&#x4E8B;&#x4E1A;&#x5C06;20000&#x5199;&#x5165;g_number......
  &#x8FD9;&#x5C31;&#x662F;&#x6211;&#x4EEC;&#x4E4B;&#x524D;&#x7684;&#x591A;&#x7EBF;&#x7A0B;&#x6848;&#x4F8B;&#x6CA1;&#x6709;&#x52A0;&#x4E92;&#x65A5;&#x9501;&#x7684;&#x60C5;&#x51B5;&#x6700;&#x7EC8;&#x7ED3;&#x679C;&#x662F;140w&#x5DE6;&#x53F3;&#x7684;&#x539F;&#x56E0;&#x3002;</p>
</blockquote>

                    
                    </section>
                
                
                </div>
            </div>
        </div>

        
        <a href="../day11/00.readme.html" class="navigation navigation-prev " aria-label="Previous page: Python语法高级专题1"><i class="fa fa-angle-left"></i></a>
        
        
        <a href="../day11/02.copy.html" class="navigation navigation-next " aria-label="Next page: 赋值-浅拷贝-深拷贝"><i class="fa fa-angle-right"></i></a>
        
    </div>
</div>

        
<script src="../gitbook/app.js"></script>

    
    <script src="../gitbook/plugins/gitbook-plugin-toggle-chapters/toggle.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-splitter/splitter.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-sharing/buttons.js"></script>
    

    
    <script src="../gitbook/plugins/gitbook-plugin-fontsettings/buttons.js"></script>
    

<script>
require(["gitbook"], function(gitbook) {
    var config = {"toggle-chapters":{},"splitter":{},"emphasize":{},"highlight":{},"sharing":{"facebook":true,"twitter":true,"google":false,"weibo":false,"instapaper":false,"vk":false,"all":["facebook","google","twitter","weibo","instapaper"]},"fontsettings":{"theme":"white","family":"sans","size":2}};
    gitbook.start(config);
});
</script>

        <!-- body:end -->
    </body>
    <!-- End of book python高级 -->
</html>
